Always pass around the store machine frame number instead of the linear address.
authorcl349@firebug.cl.cam.ac.uk <cl349@firebug.cl.cam.ac.uk>
Wed, 27 Jul 2005 17:17:09 +0000 (17:17 +0000)
committercl349@firebug.cl.cam.ac.uk <cl349@firebug.cl.cam.ac.uk>
Wed, 27 Jul 2005 17:17:09 +0000 (17:17 +0000)
Also cleanup IOCTL_PRIVCMD_INITDOMAIN_STORE.
Signed-off-by: Rusty Russel <rusty@rustcorp.com.au>
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c
tools/libxc/xc_linux_build.c
xen/include/public/xen.h

index 50c8de3eae68215aa66907a1c65b1e5e8e5f529e..e7f6ff5fcfb9fd374e5f71cb59af347cd6183a1e 100644 (file)
@@ -200,27 +200,29 @@ static int privcmd_ioctl(struct inode *inode, struct file *file,
     case IOCTL_PRIVCMD_INITDOMAIN_STORE:
     {
         extern int do_xenbus_probe(void*);
+        unsigned long page;
 
         if (xen_start_info.store_evtchn != 0) {
-            ret = -EINVAL;
+            ret = xen_start_info.store_mfn;
             break;
         }
 
         /* Allocate page. */
-        xen_start_info.store_page = get_zeroed_page(GFP_KERNEL);
-        if (!xen_start_info.store_page) {
+        page = get_zeroed_page(GFP_KERNEL);
+        if (!page) {
             ret = -ENOMEM;
             break;
         }
 
         /* We don't refcnt properly, so set reserved on page.
          * (this allocation is permanent) */
-        SetPageReserved(virt_to_page(xen_start_info.store_page));
+        SetPageReserved(virt_to_page(page));
 
         /* Initial connect. Setup channel and page. */
         xen_start_info.store_evtchn = data;
-        ret = pfn_to_mfn(virt_to_phys((void *)xen_start_info.store_page) >>
-                         PAGE_SHIFT);
+        xen_start_info.store_mfn = pfn_to_mfn(virt_to_phys((void *)page) >>
+                                              PAGE_SHIFT);
+        ret = xen_start_info.store_mfn;
 
         /* We'll return then this will wait for daemon to answer */
         kthread_run(do_xenbus_probe, NULL, "xenbus_probe");
index d402e81f5309dfd241f357f2f9a535e863c6e239..f28fa37ee2cd727c96649389a60b76dffbce44bb 100644 (file)
@@ -202,10 +202,11 @@ int xb_init_comms(void **in, void **out)
                return err;
        }
 
+       *out = machine_to_virt(xen_start_info.store_mfn << PAGE_SHIFT);
+       *in = *out + PAGE_SIZE / 2;
+
        /* FIXME zero out page -- domain builder should probably do this*/
-       memset((void *)xen_start_info.store_page, 0, PAGE_SIZE);
+       memset(*out, 0, PAGE_SIZE);
 
-       *out = (void *)xen_start_info.store_page;
-       *in = (void *)xen_start_info.store_page + PAGE_SIZE/2;
        return 0;
 }
index 6b5735d809a361c18cb95e36749b0871ea88b64f..407449dd64e36fbfc278874900f89416cbd6bc40 100644 (file)
@@ -94,7 +94,7 @@ static void *read_reply(enum xsd_sockmsg_type *type, unsigned int *len)
 void xenbus_debug_write(const char *str, unsigned int count)
 {
        struct xsd_sockmsg msg;
-       void *out = (void *)xen_start_info.store_page;
+       void *out = machine_to_virt(xen_start_info.store_mfn << PAGE_SHIFT);
 
        msg.type = XS_DEBUG;
        msg.len = sizeof("print") + count + 1;
index 27e019ca4a5beccfaae4baa6f19b1aa37ecbd4da..b0a14c7cc5f92a56e9cc680de8ad149491c3d547 100644 (file)
@@ -500,6 +500,8 @@ static int setup_guest(int xc_handle,
         goto error_out;
 #endif
 
+    *store_mfn = page_array[(vstoreinfo_start-dsi.v_start) >> PAGE_SHIFT];
+
     start_info = xc_map_foreign_range(
         xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE,
         page_array[(vstartinfo_start-dsi.v_start)>>PAGE_SHIFT]);
@@ -511,7 +513,7 @@ static int setup_guest(int xc_handle,
     start_info->nr_pt_frames = nr_pt_pages;
     start_info->mfn_list     = vphysmap_start;
     start_info->domain_controller_evtchn = control_evtchn;
-    start_info->store_page   = vstoreinfo_start;
+    start_info->store_mfn    = *store_mfn;
     start_info->store_evtchn = store_evtchn;
     if ( initrd_len != 0 )
     {
@@ -522,9 +524,6 @@ static int setup_guest(int xc_handle,
     start_info->cmd_line[MAX_GUEST_CMDLINE-1] = '\0';
     munmap(start_info, PAGE_SIZE);
 
-    /* Tell our caller where we told domain store page was. */
-    *store_mfn = page_array[((vstoreinfo_start-dsi.v_start)>>PAGE_SHIFT)];
-
     /* shared_info page starts its life empty. */
     shared_info = xc_map_foreign_range(
         xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE, shared_info_frame);
index 66ffeb60aad5b0d10ea643e7b933a979ba45b455..9255d8cb15323237b3a8a12a709702366c556c42 100644 (file)
@@ -446,7 +446,7 @@ typedef struct start_info {
     memory_t mod_start;       /* VIRTUAL address of pre-loaded module.    */
     memory_t mod_len;         /* Size (bytes) of pre-loaded module.       */
     s8 cmd_line[MAX_GUEST_CMDLINE];
-    memory_t store_page;      /* VIRTUAL address of store page.           */
+    memory_t store_mfn;       /* MACHINE page number of shared page.      */
     u16      store_evtchn;    /* Event channel for store communication.   */
 } start_info_t;